<?php

namespace app\admin\service;

use app\admin\dao\MemberMatchRecordDao;
use app\admin\model\UM as UM;
use ShidianUtil\Utils\TimeUtil;
use think\Collection;

/**
 * Class MatchRecordService
 * @package app\admin\service
 */
class MatchRecordService
{
    // dao
    private MemberMatchRecordDao $memberMatchRecordDao;

    public function __construct(MemberMatchRecordDao $memberMatchRecordDao)
    {
        $this->memberMatchRecordDao = $memberMatchRecordDao;
    }

    /**
     * 列表
     * @param UM|null $user
     * @param int|null $page
     * @param int|null $page_size
     * @return array
     */
    public function index(?UM $user, $startTime, $endTime, $kw, ?int $page = null, ?int $page_size = null): array
    {
        if (is_numeric($endTime)) {
            $endTime = TimeUtil::stamp(TimeUtil::DAY, $endTime, false);
        }

        //这里如果要修改查询，建议把查询放到dao层去
        return $this->memberMatchRecordDao->listRecords($startTime, $endTime, $kw, $page, $page_size);
    }

}
